package net.tp.algo.sort;

/**
 *
 * @author Trung Phan
 */
public class InsertionSort {
 

    public static void sort(int[] a) {
        sort(a, 0, a.length - 1);
    }

    public static void sort(int[] a, int lo, int hi) {

        for (int i = lo+1; i <= hi; i++) {
            int j = i, v = a[i];
            for (; j > 0 && a[j-1] > v; j--) {
                a[j] = a[j-1];
            }
            a[j] = v;
        }

    }

}
